/*
 * index.js
 */


var result;
$.post("http://120.77.149.2/Merchant/Orders/PageList", function(result) {
	var length = result.Data.Data.length;
	//	console.log(result.Data.Data.length);
	//      			console.log($("#sp"))
	console.log(result.Data.Data[0].CreateTime.substring(6, 19) - 0)
	
	
	var box = document.getElementById("myBox");
	var text = document.getElementById("text");
	//      var box = document.body;
	//      console.log(body)
		text.innerHTML = "共计 "+ length +" 条数据"


	for(var index = 0; index <= length; index++) {
		
		/*
		 *转换 CreateTime 时间戳
		 */
		time = result.Data.Data[index].CreateTime.substring(6, 19) - 0;
		date = new Date(time);
		Y = date.getFullYear() + '-';
		M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
		D = date.getDate() + ' ';
		h = date.getHours() + ':';
		m = date.getMinutes() + ':';
		s = date.getSeconds();
		//	console.log(Y + M + D + h + m + s);
		
		
		   /*
 			*转换 FinalTime 时间戳
 			*/
//			console.log(result.Data.Data[ 1 ].FinalTime);
//			
//		if(result.Data.Data[i].FinalTime != null){
//			var time1 = result.Data.Data[ i ].FinalTime.substring(6, 19) - 0;
//			console.log(time1)
//			var date1 = new Date(time1);
//			
//			console.log(date1.getFullYear())
//			FinalY = date1.getFullYear() + '-';
//			M1 = (date1.getMonth() + 1 < 10 ? '0' + (date1.getMonth() + 1) : date1.getMonth() + 1) + '-';
//			D1 = date1.getDate() + ' ';
//			h1 = date1.getHours() + ':';
//			m1 = date1.getMinutes() + ':';
//			s1 = date1.getSeconds();
//			}
		box.innerHTML += 
			" <tr><td class='text-center active'>" + result.Data.Data[index].Account + "</td>" +
			"<td class='text-center '>" + result.Data.Data[index].AgentId + "</td>" +
			"<td class='text-center success'>" + result.Data.Data[index].ChannelId + "</td>" +
			"<td class='text-center '>" + Y + M + D + h + m + s + "</td>" +
			"<td class='text-center warning'>" + result.Data.Data[index].FinalTime + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].Earning + "</td>" +
			"<td class='text-center danger'>" + result.Data.Data[index].Flag + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].Instcode + "</td>" +
			"<td class='text-center info'>" + result.Data.Data[index].IP + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].IsBuckle + "</td>" +
			"<td class='text-center active'>" + result.Data.Data[index].MerchantId + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].MirId + "</td>" +
			"<td class='text-center success'>" + result.Data.Data[index].MirName + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].Msg + "</td>" +
			"<td class='text-center warning'>" + result.Data.Data[index].OrderMoney + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].ProductId + "</td>" +
			"<td class='text-center danger'>" + result.Data.Data[index].ProductName + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].QQ + "</td>" +
			"<td class='text-center active'>" + result.Data.Data[index].RefUrl + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].Sent + "</td>" +
			"<td class='text-center success'>" + result.Data.Data[index].Status + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].Stop + "</td>" +
			"<td class='text-center warning'>" + result.Data.Data[index].Times + "</td>" +
			"<td class='text-center'>" + result.Data.Data[index].TransNo + "</td>" +
			"<td class='text-center danger'>" + result.Data.Data[index].Unit + "</td>"
		"</tr>  "
	
		
	}
});